package com.wz.project.sap.DN.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.sap.DN.domain.ZflWmsGetDn;
import com.wz.project.sap.DN.service.IZflWmsGetDnService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 内外向交货单Controller
 * 
 * @author wz
 * @date 2022-09-14
 */
@Controller
@RequestMapping("/system/DN")
public class ZflWmsGetDnController extends BaseController
{
    private String prefix = "sap/ZFL_WMS_GET_DN";

    @Autowired
    private IZflWmsGetDnService zflWmsGetDnService;

//    @RequiresPermissions("system:DN:view")
    @GetMapping()
    public String DN()
    {
        return prefix + "/DN";
    }

    /**
     * 查询内外向交货单列表
     */
//    @RequiresPermissions("system:DN:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZflWmsGetDn zflWmsGetDn)
    {
        startPage();
        List<ZflWmsGetDn> list = zflWmsGetDnService.selectZflWmsGetDnList(zflWmsGetDn);
        return getDataTable(list);
    }

    /**
     * 导出内外向交货单列表
     */
//    @RequiresPermissions("system:DN:export")
    @Log(title = "内外向交货单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZflWmsGetDn zflWmsGetDn)
    {
        List<ZflWmsGetDn> list = zflWmsGetDnService.selectZflWmsGetDnList(zflWmsGetDn);
        ExcelUtil<ZflWmsGetDn> util = new ExcelUtil<ZflWmsGetDn>(ZflWmsGetDn.class);
        return util.exportExcel(list, "DN");
    }

    /**
     * 新增内外向交货单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存内外向交货单
     */
    @RequiresPermissions("system:DN:add")
    @Log(title = "内外向交货单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZflWmsGetDn zflWmsGetDn)
    {
        return toAjax(zflWmsGetDnService.insertZflWmsGetDn(zflWmsGetDn));
    }

    /**
     * 修改内外向交货单
     */
    @GetMapping("/edit/{VBELN}")
    public String edit(@PathVariable("VBELN") String VBELN, ModelMap mmap)
    {
        ZflWmsGetDn zflWmsGetDn = zflWmsGetDnService.selectZflWmsGetDnById(VBELN);
        mmap.put("zflWmsGetDn", zflWmsGetDn);
        return prefix + "/edit";
    }

    /**
     * 修改保存内外向交货单
     */
    @RequiresPermissions("system:DN:edit")
    @Log(title = "内外向交货单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZflWmsGetDn zflWmsGetDn)
    {
        return toAjax(zflWmsGetDnService.updateZflWmsGetDn(zflWmsGetDn));
    }

    /**
     * 删除内外向交货单
     */
    @RequiresPermissions("system:DN:remove")
    @Log(title = "内外向交货单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zflWmsGetDnService.deleteZflWmsGetDnByIds(ids));
    }
}
